package zz.demo.springCloud.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import zz.demo.springCloud.service.SecKillService;

/**
 * Created by zhangzheng on 2017-9-21.
 */
@RestController
public class SecKillController {
    @Autowired
    private SecKillService secKillService;

    @GetMapping("/")
    public String main(){
        return "hello";
    }

    @GetMapping("/get/{username}")
    public String doSecKill(@PathVariable(value = "username")String username){
        if (username.length()!=0){
            return secKillService.doSecKill(username);
        }
        return "error";
    }

    @GetMapping("/refresh")
    public String refresh(){
        return secKillService.doRefresh();
    }

}
